import type { DataTableColumn } from 'naive-ui'
import { dataTableProps } from 'naive-ui'
import type { ExtractPropTypes, PropType } from '@vue/runtime-core'
import type { VNodeChild } from 'vue'

/**
 * @ClassName: typing
 * @Description: // 配置属性类型
 * @Author: Ellwood
 * @CreateDate: 2024/2/23 - 8:40
 * @Version: V1.0.0
 */

export interface ProTableValueEnum {
  label: string | (() => VNodeChild)
  value: string | number
}

export type ProTableColumn = DataTableColumn & {
  valueType?: 'input' | 'select'
  valueEnum?: Record<string, ProTableValueEnum>
  title?: string
  key?: string
}

export interface ProTableOptions {
  reload?: boolean
  setting?: boolean
}

export const proTableProps = {
  ...dataTableProps,
  // 自定义属性
  columns: {
    type: Array as PropType<ProTableColumn[]>,
    default: () => [],
  },
  options: {
    type: [Object, Boolean] as PropType<false | ProTableOptions>,
    default: () => ({ reload: true, setting: true }),
  },
}

export type ProTableProps = ExtractPropTypes<typeof proTableProps>
